

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Compiler Optimizations &mdash; Mosa Project  documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/css/sphinx_prompt_css.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Compiler Transformations" href="compiler-transformations.html" />
    <link rel="prev" title="Compiler Design" href="compiler-design.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> Mosa Project
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Introduction</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting-started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="demos.html">Demos</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions (FAQs)</a></li>
</ul>
<p class="caption"><span class="caption-text">Compiler</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="compiler-design.html">Compiler Design</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Compiler Optimizations</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#optimizations">Optimizations</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="compiler-transformations.html">Compiler Transformations</a></li>
</ul>
<p class="caption"><span class="caption-text">Settings</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="settings-options.html">Settings Options</a></li>
<li class="toctree-l1"><a class="reference internal" href="command-line-arguments.html">Command Line Arguments</a></li>
</ul>
<p class="caption"><span class="caption-text">Tools</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tools.html">MOSA Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="tool-compiler.html">MOSA Compiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="tool-launcher.html">MOSA Launcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="tool-launcher-console.html">MOSA Launcher Console</a></li>
<li class="toctree-l1"><a class="reference internal" href="tool-explorer.html">MOSA Explorer</a></li>
<li class="toctree-l1"><a class="reference internal" href="tool-debugger.html">MOSA Debugger</a></li>
<li class="toctree-l1"><a class="reference internal" href="tool-boot-image.html">MOSA Boot Image Tool</a></li>
</ul>
<p class="caption"><span class="caption-text">Advanced</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="unit-tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="usb-flash-drive-installation.html">USB Flash Drive Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="baremetal.html">BareMetal Experiment</a></li>
</ul>
<p class="caption"><span class="caption-text">Contribute</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="get-involved.html">Get Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="authors.html">Authors</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Mosa Project</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>Compiler Optimizations</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/compiler-optimizations.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="compiler-optimizations">
<h1>Compiler Optimizations<a class="headerlink" href="#compiler-optimizations" title="Permalink to this headline">¶</a></h1>
<div class="section" id="optimizations">
<h2>Optimizations<a class="headerlink" href="#optimizations" title="Permalink to this headline">¶</a></h2>
<dl class="simple">
<dt>Constant Folding and Propagation</dt><dd><p>Constant folding is the process of recognizing and evaluating constant expressions at compile time rather than computing them at runtime.</p>
</dd>
<dt>Strength Reduction</dt><dd><p>Strength reduction is a compiler optimization where expensive operations are replaced with equivalent but less expensive operations.</p>
</dd>
<dt>Dead Code Elimination</dt><dd><p>Dead code elimination is an optimization to remove instructions which does not affect the results of a program.</p>
</dd>
<dt>Static Single Assignment Form</dt><dd><p>In Single Static Assignment (SSA) form, all virtual registers may only have one definition. While not an immediate optimization by itself, it enables other optimization opportunities by simultaneously simplifies and improves the results of the other compiler optimizations.</p>
</dd>
<dt>Sparse Conditional Constant Propagation</dt><dd><p>Sparse conditional constant propagation is an optimization applied after conversion to static single assignment form (SSA). It simultaneously removes dead code and propagates constants. It can finds more constant values, and thus more opportunities for improvement, than other optimizations.</p>
</dd>
<dt>Global Value Numbering</dt><dd><p>Global Value numbering is a technique of determining when two computations in a program are equivalent and eliminating one of them with while preserving the same semantics.</p>
</dd>
<dt>Inline Expansion</dt><dd><p>Inline Expansion replaces a methods call site with the body of the called method. This improves the performance, because calls can be expensive (storing the registers, placing the arguments onto stack, jumping to another location).</p>
</dd>
<dt>Bit Tracker</dt><dd><p>Bit Tracker tracks the known state of bits and value ranges thru the various operations. This may enables other optimizations and shortcuts.</p>
</dd>
<dt>Block Reordering</dt><dd><p>Basic block reordering organizaze block of instructions to maximize the number of fall-through branches.</p>
</dd>
<dt>Greedy Register Allocation</dt><dd><p>Greedy Register Allocation is a form of register allocation that allocates registers based on live ranges and spill weights.</p>
</dd>
<dt>Long Expansion</dt><dd><p>Long expansion is the transformation of 64-bit instructions into 32-bit components for platforms without native 64-bit instructions. This may result in further optimization opportunities.</p>
</dd>
<dt>Two Pass Optimizations</dt><dd><p>This options causes the optimization stages to be executed again, possibility unlocked additional optimizations.</p>
</dd>
</dl>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="compiler-transformations.html" class="btn btn-neutral float-right" title="Compiler Transformations" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="compiler-design.html" class="btn btn-neutral float-left" title="Compiler Design" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2008-2020, Mosa Project &amp; contributors

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>